package main

import "fmt"

type Command interface {
	Execute()
}

type PrintCommand struct {
}

func (p *PrintCommand) Execute() {
	fmt.Println("打印消息")
}

type SendEmailCommand struct {
	To      string
	Content string
}

type TaskQueue struct {
	Queue []Command
}

func (t *TaskQueue) AddCommand(c Command) {
	t.Queue = append(t.Queue, c)
}
func (t *TaskQueue) Command() {
	for _, command := range t.Queue {
		command.Execute()
	}
}
func NewTaskQueue() *TaskQueue {
	return &TaskQueue{}
}

func (p *SendEmailCommand) Execute() {
	fmt.Println("发送邮件")
}

func main() {
	queue := NewTaskQueue()
	queue.AddCommand(&PrintCommand{})
	queue.AddCommand(&SendEmailCommand{})
	queue.Command()
}
